﻿using System;
using System.Xml.Serialization;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    /// <remarks/>
    [XmlTypeAttribute(AnonymousType = true)]
    [XmlRootAttribute(ElementName = "task", Namespace = "", IsNullable = false)]
    [ZenRestRequest("projects/{ProjectId}/stories/{StoryId}/tasks/{TaskId}", "projects/{ProjectId}/stories/{StoryId}/tasks")]
    public partial class Task : TaskUpdater, ITask
    {
        private IUser _finishedBy;

        /// <remarks/>
        [XmlElement(ElementName = "finishTime")]
        public DateTime? FinishTime { get; set; }

        public bool FinishTimeSpecified { get { return false; } }

        /// <remarks/>
        [XmlElement(ElementName = "createTime")]
        public DateTime CreateTime { get; set; }

        public bool CreateTimeSpecified { get { return false; } }

        [XmlElement(ElementName = "finishedBy")]
        public User FinishedByXmlElement
        {
            get { return _finishedBy as User; }
            set { _finishedBy = value; }
        }

        [XmlIgnore]
        public IUser FinishedBy
        {
            get { return _finishedBy; }
            set { _finishedBy = value; }
        }

        public bool FinishedByXmlElementSpecified { get { return false; } }

        [XmlIgnore]
        public new TaskStatus Status
        {
            get { return base.Status == null ? default(TaskStatus) : base.Status.Value; }
            set { base.Status = value; }
        }
    }
}